package com.emre.daoGenerator.utils;

import java.io.*;

public class JavaCodeWriter 
{
	private String fileName;
	
	private BufferedWriter out;
	
	private File file;
	
	public JavaCodeWriter(String fileName) throws IOException
	{
		this.fileName = fileName;
		
		file = new File(fileName);
		if(file.exists())
			file.delete();
		
		FileWriter fw = new FileWriter(file, false);
		out = new BufferedWriter(fw);
	}
	
	public void write(String toBeWritten, int tab) throws IOException
	{
		String finalToBeWritten = "";
		for(int i = 0; i<tab; i++)
		{
			finalToBeWritten += "\t";
		}
		finalToBeWritten += toBeWritten;
		
		finalToBeWritten += "\n";
		
		out.write(finalToBeWritten);
	}
	
	public void close() throws IOException
	{
		out.close();
	}
	
	public void writeEmptyLine() throws IOException 
	{
		out.write("\n");
	}
	
	
	

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public File getFile() {
		return file;
	}
}
